home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utilsys / rss14gmd.lha / RSys_1.4gmd / C / HandlerList.c < prev    next >
C/C++ Source or Header  |  1996-05-04  |  4KB  |  167 lines

  1. /*
  2.    ***************************************************************************
  3.    *
  4.    * Datei:
  5.    *      RSysHandlerList.c
  6.    *
  7.    * Inhalt:
  8.    *
  9.    *      --- Globale Routinen ---
  10.    *
  11.    *    void MakeHandlerList ( void );
  12.    *
  13.    *      --- Lokale  Routinen ---
  14.    *
  15.    *
  16.    * Bemerkungen:
  17.    *      Erzeugung einer Liste von Inputhandlern.
  18.    *
  19.    * Erstellungsdatum:
  20.    *      07-Jul-93     Rolf Böhme
  21.    *
  22.    * Änderungen:
  23.    *      07-Jul-93     Rolf Böhme        Erstellung
  24.    *
  25.    ***************************************************************************
  26.  */
  27.  
  28. #include "RSys.h"
  29. #include "protos.h"
  30.  
  31.  /*
  32.   * MakeHandlerList() erzeugt eine Liste aller angemeldeten
  33.   * InputHandler im System. Dazu muß ein Dummy-Handler
  34.   * installiert werden und über diesen werden die anderen
  35.   * InputHandler gefunden. Es existiert keine (!) öffentliche
  36.   * Liste mit allen InputHandlern.
  37.   */
  38. void
  39. MakeHandlerList (void)
  40. {
  41.   int count = 0, i = 0;
  42.   int j;
  43.  
  44.   MSGPORT *InputDevPort = NULL;
  45.   IOSTDREQ *InputRequestBlock = NULL;
  46.   INTERRUPT HandlerStuff;
  47.   NODE *LoopNode, *StartNode, *node;
  48.  
  49.   DPOS;
  50.  
  51.   if (InputDevPort = (MSGPORT *) CreatePort ((UBYTE *) "RSys-Check-Port", NULL))
  52.     {
  53.       if (InputRequestBlock = (IOSTDREQ *) CreateStdIO (InputDevPort))
  54.     {
  55.       if (!OpenDevice ((UBYTE *) "input.device", 0, (IOREQUEST *) InputRequestBlock, 0))
  56.         {
  57.           HandlerStuff.is_Code = NULL;
  58.           HandlerStuff.is_Data = NULL;
  59.           HandlerStuff.is_Node.ln_Pri = -127;
  60.           HandlerStuff.is_Node.ln_Name = "RSys-Check-Handler";
  61.  
  62.           InputRequestBlock->io_Command = IND_ADDHANDLER;
  63.           InputRequestBlock->io_Data = (APTR) & HandlerStuff;
  64.  
  65.           DoIO ((IOREQUEST *) InputRequestBlock);
  66.  
  67.           /*
  68.            * Da InputHandler über Interrupts gesteuert werden
  69.            * ist hier zum Auslesen ein Disable()/Enable()-
  70.            * Paar zu verwenden
  71.            */
  72.           Disable ();
  73.           {
  74.         for (j = 0, LoopNode = (NODE *) & (HandlerStuff.is_Node);
  75.              LoopNode && LoopNode->ln_Pred;
  76.              LoopNode = LoopNode->ln_Pred)
  77.           {
  78.             ++j;    /*GMD */
  79.           }
  80.  
  81.         StartNode = LoopNode->ln_Succ;
  82.  
  83.         for (count = 0, node = StartNode;
  84.              node->ln_Succ;
  85.              node = node->ln_Succ)
  86.           {
  87.             if (node != (NODE *) & (HandlerStuff.is_Node))
  88.               count++;
  89.           }
  90.           }
  91.           Enable ();
  92.  
  93.           countentries = count;
  94.  
  95.           if (NOT (NoEntries ()))
  96.         {
  97.           Entries = AllocScrollEntries (countentries);
  98.  
  99.           Disable ();
  100.           {
  101.             for (LoopNode = (NODE *) & (HandlerStuff.is_Node);
  102.              LoopNode && LoopNode->ln_Pred;
  103.              LoopNode = LoopNode->ln_Pred);
  104.  
  105.             StartNode = LoopNode->ln_Succ;
  106.  
  107.             for (node = StartNode;
  108.              node->ln_Succ && (i < countentries);
  109.              node = node->ln_Succ)
  110.               {
  111.             if (node != (NODE *) & (HandlerStuff.is_Node))
  112.               {
  113.  
  114.                 savestrcpy (Entries[i].se_obj_id.fullname,
  115.                     node, PARTSIZE, node->ln_Type);        /*GMD */
  116. //                               node, PARTSIZE, NT_INTERRUPT);
  117.  
  118.                 Entries[i].se_obj_id.address = node;
  119.  
  120.                 sprintf (Entries[i].se_Entry,
  121.                      EntryAttr[INPUTHDL].ea_dataformat,
  122.                      Entries[i].se_obj_id.address,
  123.                      Entries[i].se_obj_id.fullname,
  124.                      node->ln_Pri,
  125.                      (long) ((INTERRUPT *) node)->is_Data,
  126.                      (long) ((INTERRUPT *) node)->is_Code);
  127.  
  128.                 i++;
  129.               }
  130.               }
  131.  
  132.             countentries = i;
  133.           }
  134.           Enable ();
  135.  
  136.           CreateEntryList (SORT, 9);
  137.         }
  138.  
  139.           InputRequestBlock->io_Command = IND_REMHANDLER;
  140.           InputRequestBlock->io_Data = (APTR) & HandlerStuff;
  141.  
  142.           DoIO ((IOREQUEST *) InputRequestBlock);
  143.  
  144.           CloseDevice ((IOREQUEST *) InputRequestBlock);
  145.         }
  146.       else
  147.         {
  148.           ErrorHandle ("input.device", DEVICE_ERR, OPEN_FAIL, NO_KILL);
  149.         }
  150.  
  151.       DeleteStdIO (InputRequestBlock);
  152.     }
  153.       else
  154.     {
  155.       ErrorHandle ("CreateStdIO()", MISC_ERR, CREATE_FAIL, NO_KILL);
  156.     }
  157.  
  158.       DeletePort (InputDevPort);
  159.     }
  160.   else
  161.     {
  162.       ErrorHandle ("RSys-Check-Port", PORT_ERR, CREATE_FAIL, NO_KILL);
  163.     }
  164.  
  165.   return;
  166. }
  167.